<template>
  <!-- 发货单-发货确认 -->
  <div class="deliveryConfirmation">
    <van-nav-bar left-arrow @click-left="$router.go(-1)" />

    <van-cell-group>
      <van-cell title="客户" :value="waitShipments.cusName" />
      <van-cell title="商品" :value="waitShipments.prodName" />
      <van-cell title="数量" :value="waitShipments.prodNum" />
      <van-cell title="下单人" :value="waitShipments.orderUserName" />
      <van-cell title="下单时间" :value="waitShipments.orderTime" />
    </van-cell-group>
    <div class="biaodan">
      <van-field
        v-model="val1"
        name="收货人"
        label="收货人"
        placeholder="请填写收货人"
      />
      <van-field
        v-model="val2"
        name="收货人"
        label="联系电话"
        placeholder="请填写联系电话"
      />
      <van-field
        v-model="val3"
        name="收货地址"
        label="收货地址"
        placeholder="请填写收货地址"
      />
      <van-field
        v-model="val4"
        name="物流单号"
        label="物流单号"
        placeholder="请填写物流单号"
      />
    </div>

    <van-button type="primary" size="large" color="#039" round @click="affirm">
      确认发货信息
    </van-button>
  </div>
</template>

<script>
import { GetwaitGoodsData, deliverGoods } from "@/request/api";
export default {
  data() {
    return {
      // 接受数据
      waitShipments: [],
      // 收货人
      val1: "",
      // 联系电话
      val2: "13888888888",
      // 地址
      val3: "广东省 广州市 天河区 棠下街道 大地工业区D栋",
      // 物流单号
      val4: "",
    };
  },
  created() {
    // 转成对象后接收
    this.waitShipments = JSON.parse(this.$route.query.info);
    console.log(this.waitShipments);
    this.val1 = this.waitShipments.orderUserName;
    this.val4 = this.waitShipments.serialNo;
  },
  methods: {
    affirm() {
      // 发送发货请求
      deliverGoods({
        serialNo: this.val4,
        receiver: this.val1,
        linkPhone: this.val2,
        address: this.val3,
        logisticsCode: 41554512121,
      }).then((res) => {
        console.log(res);
      });
      this.$toast.success("操作成功");
      // 个用户反映时间
      setTimeout(() => {
        this.$router.push("/Shipments");
      }, 1000);
    },
  },
};
</script>
 
<style lang = "less" scoped>
.van-hairline--bottom {
  background-color: #003399;
}
/deep/.van-icon {
  color: #ffffff;
}
.van-cell-group {
  margin-bottom: 0.1rem;
}
/deep/.van-field__value {
  background-color: rgb(245, 244, 244);
  border-radius: 0.04rem;
  height: 0.3rem;
  line-height: 0.3rem;
}
.biaodan {
  margin-bottom: 0.2rem;
}
</style>